package com.bl.student.api.controller.sign;

import com.bl.student.api.controller.BaseController;
import com.bl.student.common.ApiResponseBody;
import com.bl.student.dao.model.UserSignEntity;
import com.bl.student.service.biz.sign.SignService;
import com.bl.student.service.vo.purchase.PurchaseListVo;
import com.bl.student.service.vo.sign.UserSignHistoryListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * Created by liangweikang on 18/8/7.
 */
@RestController
@Log4j2
@RequestMapping(value = {"/student/apis/sign"})
@Api(value = "签到api", description = "签到api")
public class SignController extends BaseController {


    @Autowired
    SignService signService;

    @ApiOperation(value = "签到", notes = "签到 ")
    @ApiImplicitParams({
    })
    @PostMapping(value = {"/add"})
    public ApiResponseBody sign(
            HttpServletRequest request) {

        signService.sign(getUserInfo(request).getId());

        return ApiResponseBody.createSuccessBody(null);
    }

    @ApiOperation(value = "用户签到天数记录", notes = "用户签到天数记录 ")
    @ApiImplicitParams({})
    @GetMapping(value = {"/get_sign"})
    public ApiResponseBody<UserSignEntity> userSign(
            HttpServletRequest request) {

        UserSignEntity userSignEntity = signService.getUserSign(getUserInfo(request).getId());

        return ApiResponseBody.createSuccessBody(userSignEntity);
    }
}
